#ifndef UARTPROCESSOR_H
#define UARTPROCESSOR_H

#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QDebug>
#include <QFile>
#include <QMessageBox>
#include <QPixmap>
#include <QImage>
#include "datasheet.h"
#include <QTextStream>
#include <QMainWindow>
#include <QRgb>
#include "uartselect.h"
class uartProcessor : public QObject
{
    Q_OBJECT
public:
    explicit uartProcessor(QObject *parent = 0,QMainWindow *w = 0);
    ~uartProcessor();
    void setTargetData(QPixmap*,DataSheet*,long long int*);
    void setMapSize(int w,int h);
    void setTargetColor(QRgb* tla,QRgb* tra,QRgb *tli,QRgb *tri,QRgb *tma)
    {
        this->lAv = tla;
        this->rAv = tra;
        this->lIav = tli;
        this->rIav = tri;
        this->mAv = tma;
    }
    void setTargetPoints(QPixmap* bmap,QPixmap*wmap)
    {
        this->blackPoint = bmap;
        this->whitePoint = wmap;
        targetImg = blackPoint->toImage();
        targetImg = targetImg.scaled(Width,Height);
    }

    int Status;
    long long int * targetOnlineData;
private:
    int Height = 120,Width = 160;
    int leftEdge = 1200,rightEdge = 1200,leftMain = 120,rightMain = 120,
    midMain = 120,extraData =55 ;
    QSerialPort *Uart;
    QMainWindow *parentMainWindow;
    QPixmap *targetMap,*blackPoint,*whitePoint;
    QImage targetImg;
    QRgb *lAv,*rAv,*lIav,*rIav,*mAv;
    DataSheet * targetDataSheet;
    QByteArray Data;
    QFile *receiveFile;
    int mapData[500][500];
    unsigned char tempData[10000];
    UartSelect *selectWindow;
    int tempCount;
    bool readable;
    void mapGenerate();
    int countStart,countEnd,countRestart;
signals:

public slots:
    void getData();
signals:
    fault();
    done();
};

#endif // UARTPROCESSOR_H
